<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>dlaqge.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="DLAQGE.1"></a><a href="dlaqge.f.html#DLAQGE.1">DLAQGE</a>( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX,
     $                   EQUED )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK auxiliary routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      CHARACTER          EQUED
      INTEGER            LDA, M, N
      DOUBLE PRECISION   AMAX, COLCND, ROWCND
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      DOUBLE PRECISION   A( LDA, * ), C( * ), R( * )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="DLAQGE.20"></a><a href="dlaqge.f.html#DLAQGE.1">DLAQGE</a> equilibrates a general M by N matrix A using the row and
</span><span class="comment">*</span><span class="comment">  column scaling factors in the vectors R and C.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  M       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The number of rows of the matrix A.  M &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The number of columns of the matrix A.  N &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
</span><span class="comment">*</span><span class="comment">          On entry, the M by N matrix A.
</span><span class="comment">*</span><span class="comment">          On exit, the equilibrated matrix.  See EQUED for the form of
</span><span class="comment">*</span><span class="comment">          the equilibrated matrix.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDA     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array A.  LDA &gt;= max(M,1).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  R       (input) DOUBLE PRECISION array, dimension (M)
</span><span class="comment">*</span><span class="comment">          The row scale factors for A.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  C       (input) DOUBLE PRECISION array, dimension (N)
</span><span class="comment">*</span><span class="comment">          The column scale factors for A.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  ROWCND  (input) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment">          Ratio of the smallest R(i) to the largest R(i).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  COLCND  (input) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment">          Ratio of the smallest C(i) to the largest C(i).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  AMAX    (input) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment">          Absolute value of largest matrix entry.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  EQUED   (output) CHARACTER*1
</span><span class="comment">*</span><span class="comment">          Specifies the form of equilibration that was done.
</span><span class="comment">*</span><span class="comment">          = 'N':  No equilibration
</span><span class="comment">*</span><span class="comment">          = 'R':  Row equilibration, i.e., A has been premultiplied by
</span><span class="comment">*</span><span class="comment">                  diag(R).
</span><span class="comment">*</span><span class="comment">          = 'C':  Column equilibration, i.e., A has been postmultiplied
</span><span class="comment">*</span><span class="comment">                  by diag(C).
</span><span class="comment">*</span><span class="comment">          = 'B':  Both row and column equilibration, i.e., A has been
</span><span class="comment">*</span><span class="comment">                  replaced by diag(R) * A * diag(C).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Internal Parameters
</span><span class="comment">*</span><span class="comment">  ===================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  THRESH is a threshold value used to decide if row or column scaling
</span><span class="comment">*</span><span class="comment">  should be done based on the ratio of the row or column scaling
</span><span class="comment">*</span><span class="comment">  factors.  If ROWCND &lt; THRESH, row scaling is done, and if
</span><span class="comment">*</span><span class="comment">  COLCND &lt; THRESH, column scaling is done.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LARGE and SMALL are threshold values used to decide if row scaling
</span><span class="comment">*</span><span class="comment">  should be done based on the absolute size of the largest matrix
</span><span class="comment">*</span><span class="comment">  element.  If AMAX &gt; LARGE or AMAX &lt; SMALL, row scaling is done.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      DOUBLE PRECISION   ONE, THRESH
      PARAMETER          ( ONE = 1.0D+0, THRESH = 0.1D+0 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      INTEGER            I, J
      DOUBLE PRECISION   CJ, LARGE, SMALL
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      DOUBLE PRECISION   <a name="DLAMCH.88"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>
      EXTERNAL           <a name="DLAMCH.89"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Quick return if possible
</span><span class="comment">*</span><span class="comment">
</span>      IF( M.LE.0 .OR. N.LE.0 ) THEN
         EQUED = <span class="string">'N'</span>
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Initialize LARGE and SMALL.
</span><span class="comment">*</span><span class="comment">
</span>      SMALL = <a name="DLAMCH.102"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'Safe minimum'</span> ) / <a name="DLAMCH.102"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'Precision'</span> )
      LARGE = ONE / SMALL
<span class="comment">*</span><span class="comment">
</span>      IF( ROWCND.GE.THRESH .AND. AMAX.GE.SMALL .AND. AMAX.LE.LARGE )
     $     THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        No row scaling
</span><span class="comment">*</span><span class="comment">
</span>         IF( COLCND.GE.THRESH ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           No column scaling
</span><span class="comment">*</span><span class="comment">
</span>            EQUED = <span class="string">'N'</span>
         ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Column scaling
</span><span class="comment">*</span><span class="comment">
</span>            DO 20 J = 1, N
               CJ = C( J )
               DO 10 I = 1, M
                  A( I, J ) = CJ*A( I, J )
   10          CONTINUE
   20       CONTINUE
            EQUED = <span class="string">'C'</span>
         END IF
      ELSE IF( COLCND.GE.THRESH ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Row scaling, no column scaling
</span><span class="comment">*</span><span class="comment">
</span>         DO 40 J = 1, N
            DO 30 I = 1, M
               A( I, J ) = R( I )*A( I, J )
   30       CONTINUE
   40    CONTINUE
         EQUED = <span class="string">'R'</span>
      ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Row and column scaling
</span><span class="comment">*</span><span class="comment">
</span>         DO 60 J = 1, N
            CJ = C( J )
            DO 50 I = 1, M
               A( I, J ) = CJ*R( I )*A( I, J )
   50       CONTINUE
   60    CONTINUE
         EQUED = <span class="string">'B'</span>
      END IF
<span class="comment">*</span><span class="comment">
</span>      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="DLAQGE.152"></a><a href="dlaqge.f.html#DLAQGE.1">DLAQGE</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
